import React, {Component} from 'react';
import './index.less';
import {base} from 'nc-lightapp-front';

const unitConf = {
    multiLang: {
        domainName: 'uapbd',
        currentLocale: 'zh-CN',
        moduleId: 'refer_uapbd',
    },
    key: 'pk_country',
    refType: 'grid',
    refName: 'refer-000444', /* 国际化处理： 国家地区EX*/
    placeholder: 'refer-000444', /* 国际化处理： 国家地区EX*/
    refCode: 'uapbd.refer.pubinfo.CountryExDefaultGridRef',
    queryGridUrl: '/nccloud/uapbd/pub/CountryExDefaultGridRef.do',
    isMultiSelectedEnabled: false,
    columnConfig: [{
        name: ['refer-000002', 'refer-000441', 'refer-000003', 'refer-000422', 'refer-000442', 'refer-000443', 'refer-000445'], /* 国际化处理： 编码,三位代码,名称,描述,时区,格式,欧盟国家*/
        code: ['refcode', 'codeth', 'refname', 'description', 'timezonename', 'formatname', 'iseucountry'],
        checked: {
            description: false,
            timezonename: false,
            formatname: false,
            iseucountry: false,
        }
    }]
};

class AddNew extends Component {
    constructor(props) {
        super(props);
        this.beforeEventHandle = this.beforeEventHandle.bind(this);
        this.afterEventHandle = this.afterEventHandle.bind(this);
    }


    afterEventHandle(props) {
        console.log(222)
        // props.form.setFormItemsValue('isclawsolve', 'N');
        // props.form.setFormItemsValue('iscomposesolve', 'N');
        // props.form.setFormItemsValue('isintercesolve', 'N');
    }

    beforeEventHandle(props, moduleId, key, item, index, value, record) {
        if (key === 'pk_psnjob') {
            let that = this;
            let {orgVal} = that.props;
            let pk_org = orgVal.refpk;
            let meta = that.props.meta.getMeta();
            meta['detail'].items.find(item => item.attrcode === key).queryCondition = function () {
                return {
                    "pk_org": pk_org,
                    "busiregionEnum": "psnpact",
                    "GridRefActionExt": "nccloud.web.hrcm.pub.sqlbuilder.PsndocQryRefSqlBuilder"
                }
            };
            that.props.meta.setMeta(meta);
        }
        return true;
    }

    render() {
        const {form} = this.props;

        return (
            <div className="disputed-query-detail">
                {form.createForm('detail', {
                    onBeforeEvent: this.beforeEventHandle,
                    onAfterEvent: this.afterEventHandle
                })
                }

            </div>
        );


    }
}

export default AddNew;
